ARG IMAGE_TAG=8.1-fpm
FROM php:${IMAGE_TAG}
ARG IMAGE_TAG

COPY --from=composer /usr/bin/composer /usr/bin/composer

ENV COMPOSER_HOME=/srv/app/storage/composer

ARG USER_ID
ARG USER_NAME
ARG ENVIRONMENT

ADD . /srv/app
WORKDIR /srv/app

RUN chmod +x bin/*.sh \
    && bin/add_user.sh \
    && bin/config_php_fpm.sh \
    && bin/config_system_mirror.sh \
    && bin/install_php_extension.sh \
    && bin/clean.sh

USER ${USER_NAME}:${USER_NAME}
